﻿using System.Collections.Generic;
using System.Web.UI.WebControls;
using Cms.Domain;
using iLib.Web.UI.WebControls;

namespace Cms.Web.UI.Admin.HelperClasses
{
    public class CategoriesDropDownHelper
    {
        public static void SetCategoryTree(ref iDropDownList ddlCategories, int level, IEnumerable<Category> categories)
        {
            foreach (Category category in categories)
            {
                string name = category.Name;
                for (int i = 0; i < level; i++)
                    name = "&nbsp;&nbsp;&nbsp;&nbsp;" + name;
                ddlCategories.Items.Add(new ListItem(name, category.ID.ToString()));
                SetCategoryTree(ref ddlCategories, level + 1, category.SubCategories);
            }
        }
    }
}